package editor.graphics;

import moltencore.game.bubble.Type;

import javax.swing.*;
import java.awt.event.MouseEvent;

public class PhysicalSpritePanel extends SpritePanel {
	private static final String BUBBLE_PRFIX = "__bubble_";
	public static final String BUBBLE_RED = BUBBLE_PRFIX + "red";
	public static final String BUBBLE_GREEN = BUBBLE_PRFIX + "green";
	public static final String BUBBLE_BLUE = BUBBLE_PRFIX + "blue";
	public static final String BUBBLE_ORANGE = BUBBLE_PRFIX + "orange";
	public static final String BUBBLE_VIOLET = BUBBLE_PRFIX + "violet";
	public static final String BUBBLE_WHITE = BUBBLE_PRFIX + "white";
	public static final String BUBBLE_BLACK = BUBBLE_PRFIX + "black";
	public static final String BUBBLE_YELLOW = BUBBLE_PRFIX + "yellow";
	public static final String BUBBLE_BLAZING = BUBBLE_PRFIX + "blazing";
	public static final String BUBBLE_STONE = BUBBLE_PRFIX + "stone";
	public static final String BUBBLE_RAINBOW = BUBBLE_PRFIX + "rainbow";
	public static final String BUBBLE_ANCHOR = BUBBLE_PRFIX + "anchor";
	public static final String BUBBLE_PUSH = BUBBLE_PRFIX + "push";
	public static final String BUBBLE_FILL = BUBBLE_PRFIX + "fill";
	public static final String NEXT = "__next";
	public static final String NEXT_NEXT = "__next_next";
	public static final String SCORE = "__score";
	public static final String RESULT = "__result";
	public static final String NICK = "__nick";
	public static final String CLOCK = "__clock";
	public static final String WALL_PREFIX = "__wall_";
	public static final String WALL_VERTICAL = WALL_PREFIX + "vertical";
	public static final String WALL_HORIZONTAL = WALL_PREFIX + "horizontal";
	public static final String RESTRICTED_AREA = "__restrictedArea";
	public static final String CRITICAL_AREA = "__criticalArea";
	public static final String KILL_AREA = "__killArea";

	public PhysicalSpritePanel(String spriteMap, String theme, String id, ImageIcon spriteImage, BrushSelectionListener brushSelectionListener) {
		super(spriteMap, theme, id, spriteImage, brushSelectionListener);
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		super.mouseClicked(e);
		if(id.equals(BUBBLE_PUSH)) {
			brushSelectionListener.pushSelected();
		}
		if(id.equals(BUBBLE_FILL)) {
			brushSelectionListener.fillSelected();
		}
		else if(id.startsWith(BUBBLE_PRFIX)) {
			notifyBubbleType();
		}
		else if(id.equals(NEXT)) {
			brushSelectionListener.nextSelected();
		}
		else if(id.equals(NEXT_NEXT)) {
			brushSelectionListener.nextNextSelected();
		}
		else if(id.equals(WALL_VERTICAL)) {
			brushSelectionListener.wallVerticalSelected();
		}
		else if(id.equals(WALL_HORIZONTAL)) {
			brushSelectionListener.wallHorizontalSelected();
		}
		else if(id.equals(RESTRICTED_AREA)) {
			brushSelectionListener.restrictedSelected();
		}
		else if(id.equals(CRITICAL_AREA)) {
			brushSelectionListener.criticalSelected();
		}
		else if(id.equals(KILL_AREA)) {
			brushSelectionListener.killSelected();
		}
		else if(id.equals(RESULT)) {
			brushSelectionListener.resultSelected();
		}
		else if(id.equals(SCORE)) {
			brushSelectionListener.scoreSelected();
		}
		else if(id.equals(NICK)) {
			brushSelectionListener.nickSelected();
		}
		else if(id.equals(CLOCK)) {
			brushSelectionListener.clockSelected();
		}
		else if(id.equals(SCORE)) {
			brushSelectionListener.scoreSelected();
		}
	}

	private void notifyBubbleType() {
		if(id.equals(BUBBLE_RED)) {
			brushSelectionListener.bubbleSelected(Type.Red);
		}
		else if(id.equals(BUBBLE_YELLOW)) {
			brushSelectionListener.bubbleSelected(Type.Yellow);
		}
		else if(id.equals(BUBBLE_GREEN)) {
			brushSelectionListener.bubbleSelected(Type.Green);
		}
		else if(id.equals(BUBBLE_ANCHOR)) {
			brushSelectionListener.bubbleSelected(Type.Anchor);
		}
		else if(id.equals(BUBBLE_BLACK)) {
			brushSelectionListener.bubbleSelected(Type.Black);
		}
		else if(id.equals(BUBBLE_BLAZING)) {
			brushSelectionListener.bubbleSelected(Type.Blazing);
		}
		else if(id.equals(BUBBLE_BLUE)) {
			brushSelectionListener.bubbleSelected(Type.Blue);
		}
		else if(id.equals(BUBBLE_ORANGE)) {
			brushSelectionListener.bubbleSelected(Type.Orange);
		}
		else if(id.equals(BUBBLE_RAINBOW)) {
			brushSelectionListener.bubbleSelected(Type.Rainbow);
		}
		else if(id.equals(BUBBLE_STONE)) {
			brushSelectionListener.bubbleSelected(Type.Ghost);
		}
		else if(id.equals(BUBBLE_VIOLET)) {
			brushSelectionListener.bubbleSelected(Type.Violet);
		}
		else if(id.equals(BUBBLE_WHITE)) {
			brushSelectionListener.bubbleSelected(Type.White);
		}
	}
}